<?php
/**
* Database Connection : Singleton
*/

class DBC {
	/**
	* Stores a database DB Object
	* @var object
	*/
	protected $db;
	
	/**
	* Create only one instance of the DB Object
	* @param object $dbo DB Object
	* @return void
	*/
	
	protected function __construct($db=NULL){
		if(is_object($db)){
			$this->db = $db;
		}else{//create a new object
			try{
				$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME;
				$this->db = new PDO($dsn, DB_USR, DB_PWD);
			}catch( Exception $e){
				die ($e->getMessage());
			}
		}
		
	}

}

?>
